package com.livestocksolutions;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;

import com.livestocksolutions.util.UpdateHistory;

/* -- Version History --
 *  1.0 : 10 July 2012 - Initial version.
 *
 *  1.1 : 16 July 2012 - Class now implements Serializable
 *  
 *  1.2 : 16 September 2012 - Added setValue(String) method to be able to use this class in
 *                       a more generalised form.
 */

/**
 * This class contains basic data for a contact.
 * <p>
 * For specific types, refer to Classes bellow.
 *  
 * @author Adam Parr
 * @version 1.1
 * 
 * @.modified 16 July 2012
 */
public class ContactDetail implements Serializable{
	/**
	 * Version number of class and value to determine un-serialised class compatibility
	 */
	private static final long serialVersionUID = 11L;

	/**
	 * Keep track of any changes of this Owner.
	 */
	protected HashMap<String,UpdateHistory> update = new HashMap<String,UpdateHistory>();

	/**
	 * ID of this contact detail.
	 */
	protected long id;
	/**
	 * Type of the Contact
	 */
	protected String type;
	/**
	 * The value of this contact
	 */
	protected String value;

	/**
	 * Constructor
	 */
	public ContactDetail(){
		id=new Date().getTime();
	}
	
	/**
	 * Get a unique value for this Contact detail.
	 * @return The long ID value for this ContactDetail.
	 */
	public long getID(){
		return id;
	}
	
	/**
	 * Set the id of this ContactDetail
	 * @param id
	 */
	public void setID(long id){
		if(this.id==0){
			this.id=id;
		}
	}
	/**
	 * Returns the type of the ContactDetail
	 * @return String containing the ContactDetail type
	 */
	public String getType(){
		return type;
	}
	
	/**
	 * Returns the value associated with this ContactDetail
	 * @return the value stored in the ContactDetail
	 */
	public String getValue(){
		return value;
	}
	
	/**
	 * Sets the type String to the given String
	 * @param type sets the type of this contact to the one given
	 */
	public void setType(String type){
		this.type=type;
	}
	
	/**
	 * Sets the value to the given String
	 * @param value The value to set for this Contact type
	 */
	public void setValue(String value){
		this.value=value;
	}
}
